package com.pycredit.util;

import java.math.BigDecimal;
import java.util.Date;

import org.joda.time.Days;
import org.joda.time.LocalDate;

public class DateUtil {

	public static int getMonthInterval(Date start, Date end) throws IllegalAccessException {
		int days = Days.daysBetween(new LocalDate(start), new LocalDate(end)).getDays();
		return new BigDecimal(MathUtil.div(days * 12 * 1.0, 365, 1)).intValue();
	}

	public static int getYearInterval(Date start, Date end) throws IllegalAccessException {
		int days = Days.daysBetween(new LocalDate(start), new LocalDate(end)).getDays();
		return new BigDecimal(MathUtil.div(days, 365, 1)).intValue();
	}

}
